﻿// main.cpp
#include <windows.h>
#include <gdiplus.h>
#include "MainWindow.h"

#pragma comment(lib, "gdiplus.lib")

// GDI+初始化
ULONG_PTR gdiplusToken;

void InitGDIPlus() {
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}

void ShutdownGDIPlus() {
    Gdiplus::GdiplusShutdown(gdiplusToken);
}

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
    // 初始化GDI+
    InitGDIPlus();
    
    // 创建主窗口
    MainWindow mainWindow(hInstance);
    if (!mainWindow.Create()) {
        ShutdownGDIPlus();
        return 1;
    }
    
    // 显示窗口
    mainWindow.Show();
    
    // 消息循环
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    
    // 关闭GDI+
    ShutdownGDIPlus();
    
    return (int)msg.wParam;
}